//
//  PayStyleCell.m
//  Ufan
//
//  Created by yangqingluo on 15/12/15.
//  Copyright © 2015年 yangqingluo. All rights reserved.
//

#import "PayStyleCell.h"

@interface PayStyleCell()

@property (strong, nonatomic) UIButton *selectedButton;
@property (strong, nonatomic) UIView *bottomLineView1;

@end

@implementation PayStyleCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.textLabel.font = [UIFont systemFontOfSize:16.0];
        
        self.detailTextLabel.font = self.textLabel.font;
        self.detailTextLabel.textColor = self.textLabel.textColor;
        self.detailTextLabel.textAlignment = NSTextAlignmentRight;
        
        _bottomLineView1 = [[UIView alloc] init];
        _bottomLineView1.backgroundColor = UFCOLOR_GRAYLINE;
        [self.contentView addSubview:_bottomLineView1];
        
        _selectedButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _selectedButton.frame = CGRectMake(0, 0, 20, 20);
        [_selectedButton setImage:[UIImage imageNamed:@"public_check_unselected"] forState:UIControlStateNormal];
        [_selectedButton setImage:[UIImage imageNamed:@"public_check_selected"] forState:UIControlStateSelected];
        _selectedButton.userInteractionEnabled = NO;
        [self.contentView addSubview:_selectedButton];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    _bottomLineView1.frame = CGRectMake(15, self.contentView.height - 1, self.contentView.width - 30, 1);
    
    self.imageView.image = [UIImage imageNamed:self.payStyle.imageName];
    self.textLabel.text = self.payStyle.name;
    self.selectedButton.selected = [self.payStyle.idString isEqualToString:[AppPublic shareInstanceApp].payStyleSelected.idString];

    self.selectedButton.center = CGPointMake(_bottomLineView1.right - 0.5 * self.selectedButton.width, 0.5 * self.contentView.height);

}

+(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}

@end
